package ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.awt.event.KeyEvent;
import java.sql.SQLException;

public class PrincipalUI extends JFrame implements ActionListener{

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JMenuBar jJMenuBar = null;
	private JMenu jmn_Menu = null;
	private JMenuItem jmnt_Clientes = null;
	private JMenuItem jmnt_Produtos = null;
	private JMenuItem jmnt_Vendas = null;
	private JSeparator jSeparator = null;
	private JMenuItem jmnt_ProdutoFalta = null;
	private JSeparator jSeparator1 = null;
	private JMenuItem jmnt_Sair = null;
	/**
	 * This is the default constructor
	 */
	public PrincipalUI() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(800, 600);
		this.setJMenuBar(getJJMenuBar());
		this.setContentPane(getJContentPane());
		this.setTitle("Loja");
		this.setResizable(false);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jJMenuBar	
	 * 	
	 * @return javax.swing.JMenuBar	
	 */
	private JMenuBar getJJMenuBar() {
		if (jJMenuBar == null) {
			jJMenuBar = new JMenuBar();
			jJMenuBar.add(getJmn_Menu());
		}
		return jJMenuBar;
	}

	/**
	 * This method initializes jmn_Menu	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getJmn_Menu() {
		if (jmn_Menu == null) {
			jmn_Menu = new JMenu();
			jmn_Menu.setText("Menu");
			jmn_Menu.add(getJmnt_Clientes());
			jmn_Menu.add(getJmnt_Produtos());
			jmn_Menu.add(getJmnt_Vendas());
			jmn_Menu.add(getJSeparator());
			jmn_Menu.add(getJmnt_ProdutoFalta());
			jmn_Menu.add(getJSeparator1());
			jmn_Menu.add(getJmnt_Sair());
		}
		return jmn_Menu;
	}

	/**
	 * This method initializes jmnt_Clientes	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getJmnt_Clientes() {
		if (jmnt_Clientes == null) {
			jmnt_Clientes = new JMenuItem();
			jmnt_Clientes.setText("Clientes");
			jmnt_Clientes.setMnemonic(KeyEvent.VK_C);
			jmnt_Clientes.addActionListener(this);
		}
		return jmnt_Clientes;
	}

	/**
	 * This method initializes jmnt_Produtos	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getJmnt_Produtos() {
		if (jmnt_Produtos == null) {
			jmnt_Produtos = new JMenuItem();
			jmnt_Produtos.setText("Produtos");
			jmnt_Produtos.setMnemonic(KeyEvent.VK_P);
		}
		return jmnt_Produtos;
	}

	/**
	 * This method initializes jmnt_Vendas	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getJmnt_Vendas() {
		if (jmnt_Vendas == null) {
			jmnt_Vendas = new JMenuItem();
			jmnt_Vendas.setText("Vendas");
			jmnt_Vendas.setMnemonic(KeyEvent.VK_V);
		}
		return jmnt_Vendas;
	}

	/**
	 * This method initializes jSeparator	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator() {
		if (jSeparator == null) {
			jSeparator = new JSeparator();
		}
		return jSeparator;
	}

	/**
	 * This method initializes jmnt_ProdutoFalta	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getJmnt_ProdutoFalta() {
		if (jmnt_ProdutoFalta == null) {
			jmnt_ProdutoFalta = new JMenuItem();
			jmnt_ProdutoFalta.setText("Produtos em Falta");
			jmnt_ProdutoFalta.setMnemonic(KeyEvent.VK_F);
		}
		return jmnt_ProdutoFalta;
	}

	/**
	 * This method initializes jSeparator1	
	 * 	
	 * @return javax.swing.JSeparator	
	 */
	private JSeparator getJSeparator1() {
		if (jSeparator1 == null) {
			jSeparator1 = new JSeparator();
		}
		return jSeparator1;
	}

	/**
	 * This method initializes jmnt_Sair	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getJmnt_Sair() {
		if (jmnt_Sair == null) {
			jmnt_Sair = new JMenuItem();
			jmnt_Sair.setText("Sair");
			jmnt_Sair.setMnemonic(KeyEvent.VK_S);
			jmnt_Sair.addActionListener(this);
		}
		return jmnt_Sair;
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == jmnt_Sair ) {
			System.exit(0);
		} else if (e.getSource() == jmnt_Clientes ) {
			try {
				new ClienteUI();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}

}
